/**
 * Copyright 2006 Bosco Curtu
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * 
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. 
 * 
 * See the License for the specific language governing permissions and limitations 
 * under the License.
*/
package com.bcurtu.james;

import java.util.Random;

public class JamesAliasGenerator {

	private String format;
	
	private final char[] letras={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

	private final char LETRA='c';
	private final char DIGIT='d';

	private Random r=new Random();

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}
	
	public String generate(){
		char[] formatarray=format.toCharArray();
		
		String alias="";
		for (char c:formatarray){
			if (c==LETRA){
				alias+=letras[Math.abs(r.nextInt())%letras.length];
			} else {
				alias+=Math.abs(r.nextInt())%10;
			}
		}
		return alias;
	}
	
}
